package com.example.speeddating.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.example.speeddating.annotaion.TimeDiffFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Getter;
import lombok.Setter;

/**
 *
 * @author tina
 * @since 2023-06-28 11:14:33
 */
@Getter
@Setter
public class Comment implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 评论id
     */
    @TableId(value = "id", type = IdType.AUTO)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 被评论的文章id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long articleId;

    /**
     * 是否删除
     */
    @TableLogic
    @JsonIgnore
    private Integer deleted;

    /**
     * 用户id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    /**
     * 评论内容
     */
    private String content;

    /**
     * 评论的时间
     */
    @TableField(fill = FieldFill.INSERT)
//    @TimeDiffFormat HH:mm:ss
    @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8")
    private Date createTime;

    /**
     * 父级评论id null就是顶级评论
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentCommentId;

    /**
     * 给评论的点赞
     */
    @TableField(exist = false)
    private Integer thumpNum;

    /**
     * 评论总数
     */
    @TableField(exist = false)
    private Integer thumpTotal;

    /**
     * 评论的评论数
     */
    private Integer commentNum;

    /**
     * 评论是否已读
     */
    private Boolean isRead;

    /**
     * 乐观锁
     */
    @Version
    @JsonIgnore
    private Integer version;


    @TableField(exist = false)
    private List<Comment> replyComments;

    @TableField(exist = false)
    private String replyNickname;

    @TableField(exist = false)
    private String nickname;

    @TableField(exist = false)
    private String avator;

    @TableField(exist = false)
    private Integer isLike; //查询本人是否有点赞

}
